#include<bits/stdc++>h>
#include "graph.h"
using namespace std;
int n,cnt,x,s[210],e[210][210],h[210],nxt[410],to[410],id[410],f[210][210],sm[210];
void add(int u,int v,int w){nxt[++cnt]=h[u],to[cnt]=v,id[cnt]=w,h[u]=cnt,f[u][v]=1;}
void dfs1(int u){
	int tmp;s[u]=NumberOfRoads();
	for(int i=1;i<=s[u];i++){
		Move(i,2),tmp=LastRoad();
		if(Color()==1)n++,add(u,n,i),add(n,u,tmp),e[n][tmp]=u,e[u][i]=n,dfs1(n);
		Move(tmp,2);
	}
}
void dfs2(int u,int lst){
	int tmp;
	if(Color()==3)f[u][x]=f[x][u]=1;
	for(int i=h[u];i;i=nxt[i])if(id[i]!=lst)Move(id[i],2),tmp=LastRoad(),dfs2(to[i],tmp),Move(tmp,2);
}
void dfs3(int u,int lst){
	int tmp;
	for(int i=h[u];i;i=nxt[i])if(id[i]!=lst)Move(id[i],2),tmp=LastRoad(),dfs3(to[i],tmp),Move(tmp,2);
	for(int i=1;i<=s[u];i++)if(!e[u][i])Move(i,2),Move(LastRoad(),3);
	x=u,dfs2(u,0);
}
void Inspect(int R){
	n=1,memset(f,63,sizeof(f)),dfs1(1),dfs3(1,0);
	for(int k=1;k<=n;k++)for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)f[i][j]=min(f[i][j],f[i][k]+f[k][j]);
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(i!=j&&f[i][j]<=R)sm[f[i][j]]++;
	for(int i=1;i<=R;i++)Answer(i,sm[i]/2);
}
